package com.zj.controller;

import com.zj.common.Result;
import com.zj.entity.Goods;
import com.zj.entity.UserInfo;
import com.zj.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    OrderService orderService;
    @PostMapping
    public Result createOrderByBuy(HttpServletRequest request,@RequestBody Goods goods){
        System.out.println(goods);
        UserInfo userInfo = (UserInfo) request.getSession().getAttribute("userInfo");
        //return null;
        return orderService.createOrderByBuy(userInfo,goods);
    }
//    public Result createOrderByExchange(UserInfo userInfo, Goods getGoods, Goods pushGoods){
//        return orderService.createOrderByExchange() ;
//    }
}
